<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./react_dom/react/react17.development.js"></script>
    <script src="./react_dom/react/react-dom17.development.js"></script>
    <script src="./react_dom/react/babel.min.js"></script>
</head>

<body>
    <div id="main"></div>
    <script type="text/babel">
        class Com extends React.Component {
            render() {
                return (<div>
                    <button onClick={this.run}>事件1</button>
                    <button onClick={this.run2}>事件2</button>
                    <button onClick={() => {
                        console.log('事件函数', this);
                        this.run3();
                    }}>事件3</button>
                    <button onClick={(e) => this.run4(e)}>事件4</button>
                    <button onClick={this.run5.bind(this)}>事件5</button>
                </div>)
            }
            run5() {
                console.log('run5555555', this);
            }
            run4(e) {
                console.log('run444444', this);
            }

            run() {
                console.log('run函数', this); //run函数 undefined
            }
            run2 = () => {
                console.log('run2', this); // 当前组件
            }

            run3(e) {
                console.log('run33333', this)// 当前组件
            }

        }
        ReactDOM.render(<Com />, document.getElementById("main"))

    </script>
</body>

</html>